package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	ProductCategoryEventNew           = "erp.ProductCategoryNew"
	ProductCategoryEventBeforeCreate  = "erp.ProductCategoryBeforeCreate"
	ProductCategoryEventBeforeUpdate  = "erp.ProductCategoryBeforeUpdate"
	ProductCategoryEventBeforeSave    = "erp.ProductCategoryBeforeCreate erp.ProductCategoryBeforeUpdate"
	ProductCategoryEventAfterCreate   = "erp.ProductCategoryAfterCreate"
	ProductCategoryEventAfterUpdate   = "erp.ProductCategoryAfterUpdate"
	ProductCategoryEventAfterSave     = "erp.ProductCategoryAfterCreate erp.ProductCategoryAfterUpdate"
	ProductCategoryEventDelete        = "erp.ProductCategoryDelete"
	ProductCategoryAccessControlEvent = "erp.ProductCategoryAccessControl"
)

func GetProductCategoryConfig() *mgo.DocConfig {
	return ProductCategory_Config
}

var ProductCategory_Config *mgo.DocConfig

func init() {
	ProductCategory_Config = NewProductCategoryConfig()
}
func NewProductCategoryConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.ProductCategory",
		Fields: []string{
			"name", "sort", "l", "r", "level", "link", "parent", "children",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetProductCategoryConfig,
				DocName:    "ProductCategory",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetProductCategoryConfig,
				DocName:    "ProductCategory",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
